<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变量的解构赋值</title>
</head>
<body>
    <script>
        //数组的解构赋值 (用的相对较少 react 里会见面)
        // let xiyou = ['唐僧','孙悟空','猪八戒','沙僧'];
        // //获取四个元素 
        // let [tang, sun, zhu, sha] = xiyou;

        // console.log(tang, sun, zhu, sha);

        //对象解构赋值 
        const zhou = {
            name: '周杰伦',
            area: '台湾省',
            songs: ['本草纲目', '龙拳', '牛仔很忙'],
            sing: function(){
                console.log('唱歌...');
            }
        };

        //对象解构赋值形式 (用的比较多)
        // let {name, sing, } = zhou;

        //复杂结构的解构赋值  (用的比较少)
        let {name, area, songs: [ben, long, niu]} = zhou;

        console.log(ben, long, niu, name, area);
        

    </script>
</body>
</html>